package com.honey.mybatis.generator.condition.method;

import com.honey.compilation.java.Clazz;
import com.honey.compilation.java.JavaKeyWord;
import com.honey.compilation.java.Parameter;
import com.honey.core.dbmapping.introspect.IntrospectSchema;
import com.honey.core.dbmapping.introspect.IntrospectSchemaColumn;
import com.honey.core.types.JDKFullyQualifiedJavaType;
import com.honey.mybatis.generator.AbstractMethod;
import com.honey.mybatis.generator.MybatisPlugin;
import com.honey.mybatis.generator.condition.ConditionConstant;

/**
 * clear 函数
 * @author Administrator
 *
 */
public class SetOrderByMethod extends AbstractMethod {
	
	public SetOrderByMethod(){
	}
	public SetOrderByMethod(Clazz clazz, MybatisPlugin belongPlugin,
			IntrospectSchema introspectSchema,
			IntrospectSchemaColumn introspectSchemaColumn) {
		super(clazz, belongPlugin, introspectSchema, introspectSchemaColumn);
	}
	
	private static final String METHOD_NAME ="setOrderBy";
	
	private static final String VARIABLE_NAME="orderBy" ;
	
	private static final String[] METHOD_BODY =new String[]{
		JavaKeyWord.OPERATION_THIS + ConditionConstant.SORT + " = "+VARIABLE_NAME	
	};
	
	private static final Parameter[] PARAMETER= new Parameter[]{
		
		new Parameter(JDKFullyQualifiedJavaType.getStringInstance(),VARIABLE_NAME )
	};
	
	private static final String[] JAVA_DOC = new String []{
		"设定排序方式。注意字符串中不包含orderby字符, 例如: fieldName DESC ."
	};
	
	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractMethod#getMethodName()
	 */
	@Override
	protected String getMethodName() {
		return METHOD_NAME;
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractMethod#getBody()
	 */
	@Override
	protected String[] getBody() {
		return METHOD_BODY;
	}

	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractMethod#getJavaDoc()
	 */
	@Override
	protected String[] getJavaDoc() {
		return JAVA_DOC;
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractMethod#getParameter()
	 */
	@Override
	protected Parameter[] getParameter() {
		
		return PARAMETER;
	}
	public static void main(String []args){
		SetOrderByMethod  cm = new SetOrderByMethod();
		System.out.println(cm.createMethod().compiledContent(0)); 
	}
}
